#ifndef wu_BASEMANAGER_H
#define wu_BASEMANAGER_H

#pragma once
#include "ofMain.h"
#include "ofxOpenCv.h"
#include "wuImagePlus.h"

enum {
    STAT_NONE,
    STAT_SKIN,
    STAT_BLOB_POS,
    STAT_GO
};

enum {
    ACT_NONE,
    ACT_CAP_SKIN,
    ACT_CAP_BLOBS,
    ACT_PLAY,
    ACT_CLEAR,
    ACT_CLEAR_PAPER,
    ACT_RAIN_ON,
    ACT_RAIN_OFF,
    ACT_ADD_FRAME,
    ACT_DELETE_FRAME,
    ACT_SAVE,
    ACT_LOAD,
    ACT_INVISIBLE_BLOB,
    ACT_PLAY_REV,
    ACT_CLEAR_ACTIVES
};

class wuBaseManager
{
    public:
        wuBaseManager();
        ~wuBaseManager();

    void setup(int _vw, int _vh);
    void capture(ofImage *currImg, ofImage *bgImg, int x_offset);
    bool action(ofImage *currImg, ofImage *bgImg, int action, int x_offset);
	virtual void addBitxo(ofImage *_skin, ofRectangle rect, vector <ofPoint> * _pts);
	void setMaxBlobs(int _maxBlobs);
	void setMinBlobSize(int _minBlobSize);
    void setMaxBlobSize(int _maxBlobSize);
	void setGrayDiff(unsigned char * _pixels);
    void setBg(ofImage *bgImg);
    void setBlur(int _vBlur);
	virtual void update();
	virtual void draw(bool pinta_bg=false, int offX=0);
	virtual void drawSelected(bool pinta_bg=false, int offX=0);
	virtual void drawInvisible(bool pinta_bg=false, int offX=0);
	virtual void setThreshold(int _thres);
	virtual void clear();
	void bypass(bool _bBypass);
	virtual void touch(int _x,int _y, int forceX=300, int forceY=0);
    int getStatus();
    virtual bool drag(int _x,int _y);
    virtual void dragOff();
    int getPriority();
    void setPriority(int _prior);
    void setScrollable(bool _bScrollable);
    virtual void setScrollOffset(int _scrollOffset);
    void setSelection(ofRectangle _selection);
    void setSelectable(bool _bSelectable);

	// dimension
    int vw, vh;

		// openCV
	ofxCvColorImage			color;
	ofxCvColorImage			bgColor;
	ofxCvGrayscaleImage		gray;
	ofxCvGrayscaleImage		bgGrayImg;
	ofxCvGrayscaleImage 	grayDiff;

	ofxCvContourFinder		contour;

	int	threshold;
	int minBlobSize, maxBlobSize;
	int maxBlobs;
    int vPriority;

	bool bGrayDiff_defined;
	bool bBg_captured;
	bool bBypass;
	bool bScrollable;
	bool bSelectable;

	int vBlur;
	int status;
	int x_scroll;

	ofRectangle selection;
};
#endif

